<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">

<!--          <el-form-item label="提现身份">-->
<!--            <el-input v-model="form.identity" style="width: 370px;" />-->
<!--          </el-form-item>-->
<!--          <el-form-item label="提现类型">-->
<!--            <el-input v-model="form.type" style="width: 370px;" />-->
<!--          </el-form-item>-->
          <el-form-item label="提现状态">
            <el-input v-model="form.status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remark" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('id')" prop="id" label="id" />
        <el-table-column v-if="columns.visible('phone')" prop="phone" label="手机号码" />
<!--        <el-table-column v-if="columns.visible('identity')" prop="identity" label="提现身份" />-->
        <el-table-column v-if="columns.visible('identity')" prop="identity" label="提现身份" >
          <template slot-scope="scope">
            {{ dict.label.identity[scope.row.identity]}}
          </template>
        </el-table-column>

<!--        <el-table-column v-if="columns.visible('type')" prop="type" label="提现类型" />-->
        <el-table-column v-if="columns.visible('type')" prop="type" label="提现类型" >
          <template slot-scope="scope">
            {{ dict.label.type[scope.row.type]}}
          </template>
        </el-table-column>

        <el-table-column v-if="columns.visible('title')" prop="title" label="提现标题" />
        <el-table-column v-if="columns.visible('amount')" prop="amount" label="提现金额" />
        <el-table-column v-if="columns.visible('fee')" prop="fee" label="手续费" />
        <el-table-column v-if="columns.visible('actual')" prop="actual" label="实际到账金额" />
        <el-table-column v-if="columns.visible('name')" prop="name" label="提现名称" />
        <el-table-column v-if="columns.visible('tos')" prop="tos" label="提现地址" />
<!--        <el-table-column v-if="columns.visible('status')" prop="status" label="提现状态" />-->

        <el-table-column v-if="columns.visible('status')" prop="status" label="提现状态" >
          <template slot-scope="scope">
            {{ dict.label.status[scope.row.status]}}
          </template>
        </el-table-column>

        <el-table-column v-if="columns.visible('remark')" prop="remark" label="备注" />
        <el-table-column v-if="columns.visible('addTime')" prop="addTime" label="创建时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.addTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('updateTimes')" prop="updateTimes" label="修改时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTimes) }}</span>
          </template>
        </el-table-column>
        <el-table-column v-permission="['admin','withdraw:edit','withdraw:del']" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudWithdraw from '@/api/withdraw'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import MaterialList from "@/components/material/index";

// crud交由presenter持有
const defaultCrud = CRUD({ title: '提现记录', url: 'api/withdraw', sort: 'id,desc', crudMethod: { ...crudWithdraw }})
const defaultForm = { id: null, phone: null, identity: null, type: null, title: null, amount: null, fee: null, actual: null, name: null, to: null, status: null, remark: null, addTime: null, updateTimes: null }
export default {
  name: 'Withdraw',
  components: { pagination, crudOperation, rrOperation, udOperation ,MaterialList},
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  dicts: ['identity','status','type'],
  data() {
    return {

      permission: {
        add: ['admin', 'withdraw:add'],
        edit: ['admin', 'withdraw:edit'],
        del: ['admin', 'withdraw:del']
      },
      rules: {
      }    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
  }
}



</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
</style>
